import request from "@/utils/request";
import Qs from "qs";

/**
 * 获取当前租户
 */
export function queryCurrentTenant() {
  return request({
    url: "/sys/tenant/queryCurrentTenant",
    method: "get",
  });
}

/**
 * 查询下级租户列表
 */
export function listInAuth(data) {
  return request({
    url: "/sys/tenant/listInAuth",
    method: "get",
    params: data,
  });
}

/**
 * 根据角色ID查询租户
 */
export function queryTenantByRoleId(params) {
  return request({
    url: "/sys/tenant/queryByRoleId",
    params,
  });
}

// 创建租户
export function createTenant(data) {
  return request({
    url: "/sys/tenant/create",
    method: "post",
    data,
  });
}

// 修改租户
export function alterTenant(data) {
  return request({
    url: "/sys/tenant/change",
    method: "put",
    data,
  });
}

// 根据ID删除租户
export function delTenantById(params) {
  return request({
    url: "/sys/tenant/deleteByIds",
    method: "delete",
    params,
    paramsSerializer: (params) => {
      return Qs.stringify(params, { indices: false });
    },
  });
}

// 根据ID查询租户
export function queryTenantById(params) {
  return request({
    url: "/sys/tenant/queryById",
    params,
  });
}
